# _*_ coding : utf-8 _*_
# @Time : 2023/3/17 0017 13:27
# @Author : 菜鸟王小二
# @File : 26_selenium定位百度元素点击前进后退
# @Project : python爬虫
import time

from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.common.by import By

path = Service('E:/chromedriver/chromedriver.exe')
driver = webdriver.Chrome(service=path)
driver.maximize_window()
driver.implicitly_wait(5)

driver.get('https://www.baidu.com')
driver.find_element(By.ID,'kw').send_keys('周杰伦')
time.sleep(2)

driver.find_element(By.ID,'su').click()
time.sleep(2)

bottom_scroll = 'document.documentElement.scrollTop = 10000'
driver.execute_script(bottom_scroll)
time.sleep(2)

driver.find_element(By.LINK_TEXT,'2').click()
time.sleep(5)

driver.execute_script(bottom_scroll)
time.sleep(2)

driver.back()
time.sleep(2)

driver.forward()
time.sleep(2)

driver.quit()

